package bowling;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Solution {
	private static final int NONE = 0, SPARE = 1, STRIKE = 2, DSTRIKE = 3;
	private static final long MAX = 1000000007;
	private static class FrameScore {
		int N, M;
		public FrameScore(int N, int M) {
			this.N = N;
			this.M = M;
		}
		@Override
		public boolean equals(Object obj) {
			if(obj instanceof FrameScore)
				return N == ((FrameScore)obj).N && M == ((FrameScore)obj).M;
			return false;
		}
	}
	private static long numSequences(FrameScore NM, int type, Map<FrameScore, Long> m) {
		Long num = m.get(NM);
		if(num != null)
			return num;
		if(type == NONE && NM.M > 30 * NM.N)
			return 0;
		if(type == SPARE && NM.M > 30 * NM.N + 10)
			return 0;
		if(type == STRIKE && NM.M > 30 * NM.N + 20)
			return 0;
		if(type == DSTRIKE && NM.M > 30 * NM.N + 30)
			return 0;
		if(NM.M == 0)
			return 1;
		
		if(NM.N <= 0) {
			if(type == SPARE) {
				if(NM.M <= 10)
					return 1;
			} else if(type == STRIKE) {
				if(NM.M <= 10)
					return NM.M + 1;
				else if(NM.M <= 20)
					return 1;
			} else if(type == DSTRIKE) {
				if(NM.M <= 10)
					return NM.M / 2 + 1;
				else if(NM.M <= 20)
					return (22 - NM.M) / 2;
				else if(NM.M <= 30)
					return 1;
			}
		}
		
		num = 0L;
		
		int max = Math.min(NM.M, 10);
		for(int i = 0; i <= max; i++) { // total score for the frame
			if(type == SPARE) {
				for(int j = 0; j <= i; j++) // score for the first ball
					num = (num + numSequences(new FrameScore(NM.N - 1, NM.M - j - i), i < 10 ? NONE : (j < 10 ? SPARE : STRIKE), m)) % MAX;
			} else if(type == STRIKE) {
				if(i < 10)
					num = (num + (i + 1) * numSequences(new FrameScore(NM.N - 1, NM.M - 2 * i), NONE, m)) % MAX;
				else {
					num = (num + i * numSequences(new FrameScore(NM.N - 1, NM.M - 2 * i), SPARE, m)) % MAX;
					num = (num + numSequences(new FrameScore(NM.N - 1, NM.M - 2 * i), DSTRIKE, m)) % MAX;
				}
			} else if(type == DSTRIKE) {
				for(int j = 0; j <= i; j++) // score for the first ball
					num = (num + numSequences(new FrameScore(NM.N - 1, NM.M - 2 * i - j), i < 10 ? NONE : (j < 10 ? SPARE : DSTRIKE), m)) % MAX;
			} else {
				if(i < 10)
					num = (num + (i + 1) * numSequences(new FrameScore(NM.N - 1, NM.M - i), NONE, m)) % MAX;
				else {
					num = (num + i * numSequences(new FrameScore(NM.N - 1, NM.M - i), SPARE, m)) % MAX;
					num = (num + numSequences(new FrameScore(NM.N - 1, NM.M - i), STRIKE, m)) % MAX;
				}
			}
		}
		
		m.put(NM, num);
		return num;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		try {
			int T = in.nextInt();
			for(int t = 0; t < T; t++) {
				int N = in.nextInt(), M = in.nextInt();
				System.out.println(numSequences(new FrameScore(N, M), NONE, new HashMap<FrameScore, Long>()));
			}
		} finally {
			in.close();
		}
	}
}
